define(function(require) {
	var $ = require("jquery");
	var justep = require("$UI/system/lib/justep");

	var Model = function() {
		this.callParent();
		this.deleteList = [];
	};

	Model.prototype.modelParamsReceive = function(event) {
		this.comp("programlistData").loadData(event.data.data);
	};

	Model.prototype.closeBtnClick = function(event) {
		var self = this;
		var count = this.comp("programlistData").count();
		if (count < this.params.data.length) {
			this.owner.send({
				deleteList : self.deleteList,
				message : "更新"
			});
		} else {
			this.close();
		}

	};

	Model.prototype.button1Click = function(event) {
		var row = event.bindingContext.$object;
		var self = this;
		justep.Util.confirm("需要删除当前分组配置参数信息，请点击确认！", function() {
			$.ajax({
				type : "DELETE",
				url : '/config/config/group/' + row.val("fvalue"),
				async : true,
				success : function(resultData, textStatus, jqXHR) {
					self.deleteList.push(row);
					self.comp("programlistData").deleteData(row);
				},
				error : function(err) {
					justep.Util.hint("网络错误，请稍后重试！", {
						"type" : "warning"
					});
				}
			});
			$.ajax({
				type : "DELETE",
				url : '/config/config/'+ row.val("id"),
				async : true,
				success : function(resultData, textStatus, jqXHR) {
					
				},
				error : function(err) {
					justep.Util.hint("网络错误，请稍后重试！", {
						"type" : "warning"
					});
				}
			});
		});
	};

	return Model;
});